﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using GreatB2C.Config.SiteInfo;

namespace GreatB2C.Web.Manage.SystemSet.SiteInfo
{
    public partial class RSSSet : Inherit.ManagePage
    {
        protected void Page_Load( object sender , EventArgs e )
        {
            if ( !IsPostBack )
            {
                LoadSetting( );
            }
        }

        protected void LoadSetting( )
        {
            radlRssEnable.SelectedValue = RSSConfig.RssEnable.ToString( );
            radlWapEnable.SelectedValue = RSSConfig.WapEnable.ToString( );
            radlWapSiteStatus.SelectedValue = RSSConfig.WapSiteStatus.ToString( );
            txtWapSiteUrl.Text = RSSConfig.WapSiteUrl.ToString( );
            txtImageHeight.Text = RSSConfig.ImageHeight.ToString( );
            txtImageWidth.Text = RSSConfig.ImageWidth.ToString( );
            ddlThumbsMode.SelectedValue = RSSConfig.ThumbsMode.ToString( );
        }

        protected void BtnSubmit_Click( object sender , EventArgs e )
        {
            bool isSuccess = RSSConfig.Config( radlRssEnable.SelectedValue.ToString( ) , radlWapEnable.SelectedValue.ToString( ) , radlWapSiteStatus.SelectedValue.ToString( ) , txtWapSiteUrl.Text.Trim( )
            , txtImageHeight.Text.Trim( ) , txtImageWidth.Text.Trim( ) , ddlThumbsMode.SelectedValue.ToString( ) );

            if ( isSuccess )
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "RSS/WAP参数配置成功！" ) + "&rtn=SystemSet/SiteInfo/RSSSet.aspx" );
            }
            else
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "RSS/WAP参数配置失败，请联系管理员！" ) + "&rtn=SystemSet/SiteInfo/RSSSet.aspx" );
            }
        }
    }
}
